function getIn(target, keyPath, notFoundValue = undefined) {
  let key
  for (let i = 0; i < keyPath.length; i++) {
    key = keyPath[i]
    // eslint-disable-next-line no-prototype-builtins
    if (target && target.hasOwnProperty(key)) {
      target = target[key]
    } else {
      return notFoundValue
    }
  }

  return target
}

export function get(target, keyPathStr, notFoundValue = undefined) {
  return getIn(target, keyPathStr.split('.'), notFoundValue)
}
